Full source code website bán hàng thương mại điện tử gần giống shopee
468.945 lượt xem;
1 <table height="28" cellSpacing="0" cellPadding="0" width="100%" border="0">
2 <tr align=center>
3 <td class="title" width="100%">Template : <a href="./?act=template_m&page=<? echo $_REQUEST['page']; ?>"><font class="V10pt" color="#ffffff">Nhập Mới</font></a>
4 </td>
5 </tr>
6 </table>
7 <?
8 switch ($_GET['action'])
9 {
10 case 'del' :
11 $id = $_GET['id'];
12 $sql="select * from template where id=$id limit 1";
13 $pro=mysql_fetch_assoc(mysql_query($sql,$con));
14 $link="../";
15 if ($pro)
16 {
17 $sql = "delete from template where id='".$id."'";
18 $result = mysql_query($sql,$con);
19 if ($result)
20 {
21 if (file_exists($link.$pro['image'])) unlink($link.$pro['image']);
22 echo "<p align=center class='err'>Đã xóa thành công</p>";
23 }
24 else echo "<p align=center class='err'>Không thể xóa dữ liệu</p>";
25 }
26 break;
27 }
28 ?>
29
30 <?
31 if (isset($_POST['ButDel'])) {
32 $cnt=0;
33 foreach ($_POST['chk'] as $id)
34 {
35 $sql="select * from template where id=$id limit 1";
36 $pro=mysql_fetch_assoc(mysql_query($sql,$con));
37 $link="../";
38 if ($pro)
39 {
40 @$result = mysql_query("delete from template where id='".$id."'",$con);
41 if ($result) {
42 $cnt++;
43 if (file_exists($link.$pro['image'])) unlink($link.$pro['image']);
44 }
45 }
46 }
47 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
48 }
49 ?>
50
51 <?
52 $page = $_GET["page"];
53 $MAXPAGE=40;
54 $p=0;
55 if ($page!='') $p=$page;
56 ?>
57 <form method="POST" name="frmList" action="index.php">
58 <input type="hidden" name="act" value="template">
59 <input type=hidden name="page" value="<? echo $page; ?>">
60 <?
61 function taotrang($sql,$link,$nitem,$itemcurrent)
62 { global $con;
63 $ret="";
64 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
65 $value = mysql_fetch_array($result);
66 $plus = (($value['cnt'] % $nitem)>0);
67 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
68 {
69 if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
70 else $ret .= ($i+1)." ";
71 }
72 return $ret;
73 }
74 $pageindex=taotrang("select count(*) from template","./?act=template"."&page=",$MAXPAGE,$page);
75 ?>
76
77 <table cellspacing="0" cellpadding="0" width="100%">
78 <? if ($_REQUEST['code']==1) echo '<tr><td align="center" class="err">Đã cập nhật thành công</td></tr>'; ?>
79 <tr>
80 <td class="smallfont">Trang : <? echo $pageindex; ?></td>
81 </tr>
82 </table>
83
84 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
85 <tr>
86 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
87 <td colspan="2" nowrap class="title"> </td>
88 <td align="center" nowrap class="title"><b>ID</b></td>
89 <td align="center" nowrap class="title"><b>Tên</b></td>
90 <td align="center" nowrap class="title"><b>Hình</b></td>
91 <td align="center" nowrap class="title"><b>Folder</b></td>
92 <td align="center" nowrap class="title"><b>Demo</b></td>
93 <td align="center" nowrap class="title"><b>Ngày</b></td>
94 </tr>
95
96 <?php
97 $sql="select * from template order by id limit ".($p*$MAXPAGE).",".$MAXPAGE;
98 $result=mysql_query($sql,$con);
99 $i=0;
100 while(($row=mysql_fetch_array($result)))
101 {
102 $i++;
103 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
104 ?>
105
106 <tr>
107 <td align="center" bgcolor="<? echo $color; ?>" class="smallfont">
108 <input type="checkbox" name="chk[]" value="<? echo $row['id']; ?>"></td>
109 <td align="center" bgcolor="<? echo $color; ?>" class="smallfont">
110 <a href="./?act=template_m&id=<? echo $row['id']; ?>&page=<? echo $_REQUEST['page'];?>">Sửa</a></td>
111 <td align="center" bgcolor="<? echo $color; ?>" class="smallfont">
112 <a onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" href="./?act=template&page=<? echo $_REQUEST['page']; ?>&action=del&id=<? echo $row['id']; ?>">Xóa</a></td>
113 <td bgcolor="<? echo $color; ?>" align="left" align="left" class="smallfont"><? echo $row['id']; ?> </td>
114 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['name']; ?> </td>
115 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['image']; ?> </td>
116 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['folder']; ?> </td>
117 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['demo']; ?> </td>
118 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['date']; ?> </td>
119 </tr>
120 <?
121 }
122 ?>
123 </table>
124 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button">
125 </form>
126 <script language="JavaScript">
127 function chkallClick(o) {
128 var form = document.frmList;
129 for (var i = 0; i < form.elements.length; i++) {
130 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
131 form.elements[i].checked = document.frmList.chkall.checked;
132 }
133 }
134 }
135 </script>
2 <tr align=center>
3 <td class="title" width="100%">Template : <a href="./?act=template_m&page=<? echo $_REQUEST['page']; ?>"><font class="V10pt" color="#ffffff">Nhập Mới</font></a>
4 </td>
5 </tr>
6 </table>
7 <?
8 switch ($_GET['action'])
9 {
10 case 'del' :
11 $id = $_GET['id'];
12 $sql="select * from template where id=$id limit 1";
13 $pro=mysql_fetch_assoc(mysql_query($sql,$con));
14 $link="../";
15 if ($pro)
16 {
17 $sql = "delete from template where id='".$id."'";
18 $result = mysql_query($sql,$con);
19 if ($result)
20 {
21 if (file_exists($link.$pro['image'])) unlink($link.$pro['image']);
22 echo "<p align=center class='err'>Đã xóa thành công</p>";
23 }
24 else echo "<p align=center class='err'>Không thể xóa dữ liệu</p>";
25 }
26 break;
27 }
28 ?>
29
30 <?
31 if (isset($_POST['ButDel'])) {
32 $cnt=0;
33 foreach ($_POST['chk'] as $id)
34 {
35 $sql="select * from template where id=$id limit 1";
36 $pro=mysql_fetch_assoc(mysql_query($sql,$con));
37 $link="../";
38 if ($pro)
39 {
40 @$result = mysql_query("delete from template where id='".$id."'",$con);
41 if ($result) {
42 $cnt++;
43 if (file_exists($link.$pro['image'])) unlink($link.$pro['image']);
44 }
45 }
46 }
47 echo "<p align=center class='err'>Đã xóa ".$cnt." phần tử</p>";
48 }
49 ?>
50
51 <?
52 $page = $_GET["page"];
53 $MAXPAGE=40;
54 $p=0;
55 if ($page!='') $p=$page;
56 ?>
57 <form method="POST" name="frmList" action="index.php">
58 <input type="hidden" name="act" value="template">
59 <input type=hidden name="page" value="<? echo $page; ?>">
60 <?
61 function taotrang($sql,$link,$nitem,$itemcurrent)
62 { global $con;
63 $ret="";
64 $result = mysql_query($sql, $con) or die('Error' . mysql_error());
65 $value = mysql_fetch_array($result);
66 $plus = (($value['cnt'] % $nitem)>0);
67 for ($i=0;$i<($value[0] / $nitem) + plus;$i++)
68 {
69 if ($i<>$itemcurrent) $ret .= "<a href=\"".$link.$i."\" class=\"lslink\">".($i+1)."</a> ";
70 else $ret .= ($i+1)." ";
71 }
72 return $ret;
73 }
74 $pageindex=taotrang("select count(*) from template","./?act=template"."&page=",$MAXPAGE,$page);
75 ?>
76
77 <table cellspacing="0" cellpadding="0" width="100%">
78 <? if ($_REQUEST['code']==1) echo '<tr><td align="center" class="err">Đã cập nhật thành công</td></tr>'; ?>
79 <tr>
80 <td class="smallfont">Trang : <? echo $pageindex; ?></td>
81 </tr>
82 </table>
83
84 <table border="1" cellpadding="2" style="border-collapse: collapse" bordercolor="#C9C9C9" width="100%" id="AutoNumber1">
85 <tr>
86 <td align=center nowrap class="title"><input type="checkbox" name="chkall" onclick="chkallClick(this);"></td>
87 <td colspan="2" nowrap class="title"> </td>
88 <td align="center" nowrap class="title"><b>ID</b></td>
89 <td align="center" nowrap class="title"><b>Tên</b></td>
90 <td align="center" nowrap class="title"><b>Hình</b></td>
91 <td align="center" nowrap class="title"><b>Folder</b></td>
92 <td align="center" nowrap class="title"><b>Demo</b></td>
93 <td align="center" nowrap class="title"><b>Ngày</b></td>
94 </tr>
95
96 <?php
97 $sql="select * from template order by id limit ".($p*$MAXPAGE).",".$MAXPAGE;
98 $result=mysql_query($sql,$con);
99 $i=0;
100 while(($row=mysql_fetch_array($result)))
101 {
102 $i++;
103 if ($i%2) $color="#d5d5d5"; else $color="#e5e5e5";
104 ?>
105
106 <tr>
107 <td align="center" bgcolor="<? echo $color; ?>" class="smallfont">
108 <input type="checkbox" name="chk[]" value="<? echo $row['id']; ?>"></td>
109 <td align="center" bgcolor="<? echo $color; ?>" class="smallfont">
110 <a href="./?act=template_m&id=<? echo $row['id']; ?>&page=<? echo $_REQUEST['page'];?>">Sửa</a></td>
111 <td align="center" bgcolor="<? echo $color; ?>" class="smallfont">
112 <a onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" href="./?act=template&page=<? echo $_REQUEST['page']; ?>&action=del&id=<? echo $row['id']; ?>">Xóa</a></td>
113 <td bgcolor="<? echo $color; ?>" align="left" align="left" class="smallfont"><? echo $row['id']; ?> </td>
114 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['name']; ?> </td>
115 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['image']; ?> </td>
116 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['folder']; ?> </td>
117 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['demo']; ?> </td>
118 <td bgcolor="<? echo $color; ?>" class="smallfont"><? echo $row['date']; ?> </td>
119 </tr>
120 <?
121 }
122 ?>
123 </table>
124 <input type="submit" value="Xóa Chọn" name="ButDel" onclick="return confirm('Bạn có chắc chắn muốn xoá ?');" class="button">
125 </form>
126 <script language="JavaScript">
127 function chkallClick(o) {
128 var form = document.frmList;
129 for (var i = 0; i < form.elements.length; i++) {
130 if (form.elements[i].type == "checkbox" && form.elements[i].name!="chkall") {
131 form.elements[i].checked = document.frmList.chkall.checked;
132 }
133 }
134 }
135 </script>